﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace Inspired.Euler
{
    public static class Problem097
    {
        /// <summary>
        /// Find the last ten digits of the non-Mersenne prime: 28433 &times; 2<sup>7830457</sup> + 1.
        /// </summary>
        [EulerProblem(97, Title = "Find the last ten digits of the non-Mersenne prime: 28433 &times; 2<sup>7830457</sup> + 1.")]
        public static long Solve()
        {
            BigInteger last10 = new BigInteger();
            BigInteger nonMersenne = BigInteger.Multiply(new BigInteger(28433), BigInteger.Pow(2, 7830457)) + 1;
            BigInteger.DivRem(nonMersenne, BigInteger.Pow(10, 10), out last10);

            return (long)last10;
        }
    }
}
